package myPack1;

import java.util.concurrent.TimeUnit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class UploadFile {
	
	WebDriver driver;
	String url;
	
	@Before
	public void launchBrowser() throws Exception{
		driver = new FirefoxDriver();
		
		driver.manage().window().maximize();
		
		url = "https://accounts.google.com/ServiceLogin?service=oz&passive=1209600&continue=https://plus.google.com/photos?tab%3Dwq%26gpsrc%3Dgplp0";
		driver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);
	}
	
	@Test
	public void atTest() throws Exception{
		//Test Case logic
		
		driver.get(url);
		
		driver.findElement(By.id("Email")).sendKeys("vijayraw123");
		
		driver.findElement(By.name("Passwd")).sendKeys("123vijayraw");
		
		driver.findElement(By.id("signIn")).click();
		
		Thread.sleep(9000);
		
		try{
			driver.findElement(By.xpath("//span[text() = 'No, thanks']")).click();
		}catch(Exception e){
			System.out.println("Pop up is not found.");
		}
		
		driver.findElement(By.xpath("//div[text() = 'Upload photos']")).click();
		
		driver.findElement(By.xpath("//div[text() = 'Click to open the file browser.']")).click();
		
		//Call to .exe to upload file
		
		Process process = new ProcessBuilder("D:\\Selenium_Files\\UploadFiles\\uploadFile.exe","D:\\abc.JPG","File Upload").start();
		
		//Process proc = new Process
		
		
		//
		driver.findElement(By.xpath("//div[text() = 'Done']")).click();
	}
	
	@After
	public void atAfter() throws Exception{
		
	}

}
